package com.gmaf.mas.launch.resloader;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

public class CompositeResourceLoader implements ResourceLoader
{
	private List<ResourceLoader> resLoaders = null;
	public CompositeResourceLoader()
	{
	}
	
	public List<ResourceLoader> getResourceLoaders()
	{
		if(resLoaders == null)
		{
			resLoaders = new ArrayList<ResourceLoader>();
		}
		return resLoaders;
	}
	
	
	@Override
	public URL getResource(String name)
	{
		List<ResourceLoader> resourceLoaders = getResourceLoaders();
		for(ResourceLoader resLoader : resourceLoaders)
		{
			URL url = resLoader.getResource(name);
			if(url != null)
			{
				return url;
			}
		}
		return null;
	}

	public String toString()
	{
		List<ResourceLoader> loaders = getResourceLoaders();
		return "CompositeResourceLoader: " + loaders.toString();
	}
}
